import { HashRouter,BrowserRouter,Route,Routes,Link,useRoutes } from "react-router-dom";
import Layout from "@/pages/layout/index";
import Login from "@/pages/login/index";
import Dashhoard from '@/pages/dashboard/index';
import GoodForm from '@/pages/good/goodForm';
import GoodList from '@/pages/good/goodList';
import User from '@/pages/user';
import store from "@/store/index"
import {Provider} from 'react-redux'
import { asyncRoutes } from "./pages";
import Permission from './Permission'
// function createRoutes(accessRoutes){
//     let result = []
//     accessRoutes.forEach(route => {
//         if(route.path&&route.element){
//             result.push(
//                 <Route key={route.key} path={route.path} element={route.element}></Route>
//             )
//         }
//         if(route.children){
//             route.children.forEach(route=>{
//                 result.push(
//                     <Route key={route.key} path={route.path} element={route.element}></Route>
//                 )
//             })
//         }
//     });
//     return result
// }


export default ()=>{
    return(
        <HashRouter>
            <Provider store={store}>
                  {/* <Link to='/'>首页</Link>
                 <Link to='/login'>登录</Link> */}
          
           <Permission></Permission>
            </Provider>
          
        </HashRouter>
    )
}
// import { HashRouter, BrowserRouter, Routes, Route, Link } from "react-router-dom"

// import Layout from "@/pages/layout/index.jsx";
// import Login from "@/pages/login/index.jsx";
// import Dashboard from "@/pages/dashboard";
// import GoodForm from "@/pages/good/goodForm";
// import GoodList from "@/pages/good/goodList";
// import User from "@/pages/user";

// import { asyncRoutes } from "./pages/index.jsx"


// // accessRoutes 可访问的路由
// function createRoutes(accessRoutes) {
//     let result = [];

//     accessRoutes.forEach(route => {
//         if (route.path && route.element) {
//             result.push(
//                 <Route key={route.key} path={route.path} element={route.element}></Route>
//             )
//         }
//         if (route.children) {
//             route.children.forEach(route => {
//                 result.push(
//                     <Route key={route.key} path={route.path} element={route.element}></Route>
//                 )
//             })
//         }
//     })

//     return result;
// }

// // createRoutes(asyncRoutes)


// function App() {
//     return (
//         <HashRouter>
//             <Routes>
//                 {/* 在React中，一级路由是不需要指定出口 */}
//                 <Route path="/" element={<Layout />}>
//                     {/* 二级路由需要指定出口 */}
//                     {/* <Route path="/dashboard" element={<Dashboard />}></Route>
//                     <Route path="/good/list" element={<GoodList />}></Route>
//                     <Route path="/user" element={<User />}></Route> */}

//                     {
//                         createRoutes(asyncRoutes)
//                     }
//                 </Route>
//                 <Route path="/login" element={<Login />}></Route>
//             </Routes>
//         </HashRouter>
//     );
// }
// export default App;
